﻿<html>
<head>
	<title>Zero Clipboard Test</title>
	

</head>
<body>

<textarea id="fe_text" cols=50 rows=5 >复制内容文本1</textarea>
<span id="clip_container"><span id="clip_button"><b>复制</b></span></span>

<br>
by <a href=http://www.piaoyi.org>www.piaoyi.org</a>
</body>
</html>
<script src="/js/lib/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="ZeroClipboard.js"></script>
<script language="JavaScript">


	
	
/**
	@hz
	@title 复制到剪贴板
	@param config obj
	@demo 
	copyToClipboard({
		copyTxt:'text',//必填 需要复制的文字
		copyAlert:'复制成功',//必填 复制成功提示文字
		copyInnerId:'clip_button',//必填 拷贝按钮需要2个ID值
		copyOutsideId:'clip_container'//必填 拷贝按钮需要2个ID值
	})
*/
function copyToClipboard(config) {
	var clip = new ZeroClipboard.Client();
	clip.setHandCursor(true);  	
	clip.addEventListener('mouseOver', function (client) {
		clip.setText(config.copyTxt);
	});
	clip.addEventListener('complete', function (client, text) {
		alert(config.copyAlert);
	});
	clip.glue(config.copyInnerId,config.copyOutsideId);
}


	var config2 = {
		"copyTxt":$("#fe_text").val(),
		"copyAlert":'复制成功',
		"copyInnerId":'clip_button',
		"copyOutsideId":'clip_container'
	}
	copyToClipboard(config2)



</script>
